{
  "properties" : { },
  "id" : "59f85e19e796456e8cec61b5eb07efe2",
  "script" : null,
  "groupId" : "74af8e1135d2474eb9b6b4081e6d5967",
  "name" : "添加编辑拓扑图信息",
  "createTime" : 1727071049463,
  "updateTime" : 1726653346940,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "submit",
  "method" : "POST",
  "parameters" : [ {
    "name" : "deptid",
    "value" : "3",
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  }, {
    "name" : "newstate",
    "value" : "0",
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  }, {
    "name" : "toponame",
    "value" : "toponame",
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  }, {
    "name" : "gplot",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "MultipartFile",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  } ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": {\n        \"msg\": \"已有该网点信息，不可重复添加\",\n        \"success\": false\n    }\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  },
  "responseBodyDefinition" : {
    "name" : "",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "Object",
    "type" : null,
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "status",
      "value" : "200",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "message",
      "value" : "success",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "data",
      "value" : "",
      "description" : "",
      "required" : false,
      "dataType" : "Object",
      "type" : null,
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ {
        "name" : "msg",
        "value" : "已有该网点信息，不可重复添加",
        "description" : "",
        "required" : false,
        "dataType" : "String",
        "type" : null,
        "defaultValue" : null,
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ ]
      }, {
        "name" : "success",
        "value" : "false",
        "description" : "",
        "required" : false,
        "dataType" : "Boolean",
        "type" : null,
        "defaultValue" : null,
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ ]
      } ]
    } ]
  }
}
================================
 import com.alibaba.fastjson.JSONObject
 import com.kd.ndmp.util.IdUtil
 import org.springframework.util.CollectionUtils
 import org.springblade.core.tool.utils.DateUtil
 import javax.sql.rowset.serial.SerialBlob
 import request
 import org.springframework.web.multipart.MultipartHttpServletRequest
 import java.io.InputStream
 import java.io.ByteArrayOutputStream
 import org.springblade.core.tool.utils.StringUtil


 MultipartHttpServletRequest params = (request);
 JSONObject result = new JSONObject();
 String deptId = deptid; //组织机构ID




 InputStream inputStream = gplot.getInputStream();

 var bytes = new_byte_array(1000000);

 ByteArrayOutputStream output = new ByteArrayOutputStream();
 var buffer = new_byte_array(4096);
 int n = 0;
 while (-1 != (n = inputStream.read(buffer))) {
     output.write(buffer, 0, n);
 }
 bytes = output.toByteArray();

 //将拓扑图转换为blob
 //  Blob blob = null;


 //  blob = new SerialBlob(gplot.bytes);
 //  bytes = BlobToByteUtil.blobToByte(blob); //将blob转换为byte数组

 Date now = DateUtil.now();

 var topoMsg = {
     "topoid": StringUtil.random(32),
     "deptid": deptId,
     "toponame": toponame,
     "gplot": bytes,
     "newstate": newstate,
     "lastdate": DateUtil.formatDateTime(now),
     "isvalid": "1",

 }
 var hisMsgId = IdUtil.getSnowflakeNextId()
 var hisMsg = {
     "id": hisMsgId,
     "deptId": deptId,
     "topology": bytes,
     "updateDate": new Date()

 }

 db.table("ndmp_topo_msg_history").insert(hisMsg)

 // 删除大于10条的记录
 List updateDate = db.select("""
 SELECT update_date FROM ndmp_topo_msg_history
        WHERE 1 = 1
        <if test="deptId != null">
            and dept_id = #{deptId}
        </if>
        ORDER BY update_date desc LIMIT 9,1""")

 if (!CollectionUtils.isEmpty(updateDate)) {
     var update_date = updateDate[0].get("updateDate")
     db.update("""
        DELETE FROM ndmp_topo_msg_history
        WHERE 1 = 1
        <if test="deptId != null">
            and dept_id = #{deptId}
        </if>
        <if test="update_date != null and update_date != ''">
            and update_date &lt; #{update_date}
        </if>
     """)

 }

 //newState状态为0时直接进行新增操作
 if ("0".equals(newstate)) {
     //新增时，同一站点不允许重复操作,查询是否有此站点信息
     int count = db.table("ndmp_topo_msg").where().eq("isvalid", "1").eq("deptid", deptid).count()
     if (0 == count) {
         int res = db.table("ndmp_topo_msg").insert(topoMsg);

         if (true == res) {
             result.put("success", res);
             result.put("msg", "保存成功");
         } else {
             result.put("success", res);
             result.put("msg", "保存失败");
         }
     } else {
         result.put("success", false);
         result.put("msg", "已有该网点信息，不可重复添加");
         return result;
     }
 }
 //newState状态为1时进行编辑操作
 if ("1".equals(newstate)) {
     //修改接口 
     var res = db.table("ndmp_topo_msg").primary("deptid").update(topoMsg)

     if (1 == res) {
         result.put("success", true);
         result.put("msg", "保存成功");
     } else {
         result.put("success", false);
         result.put("msg", "保存失败");
     }
 }
 return result;